package io.litchi.auth.Infrastructure.handler;

import io.litchi.auth.Infrastructure.util.ResponseUtil;
import io.litchi.common.result.Result;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import java.io.IOException;

/**
 * description:
 *
 * @author helang
 * @since 2025-09-10
 */

public class LitchiLogoutSuccessHandler implements LogoutSuccessHandler {

    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
        //todo 处理退出登录 普通业务 采用前端销毁token 即可 考虑安全性 可以添加token黑名单 过期时间和剩余时间保持一致
        // 或者携带请求参数 通过参数确定是否添加token黑名单
        Result<Void> result = Result.success();
        ResponseUtil.writeJsonResponse(response, result);
    }
}